import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ObjectMapper as OM;


def jsonMapper = new ObjectMapper();


class GroovyObject {
    def name;
    def age;
    GroovyObject next;
}


def a = new GroovyObject(name:'jiming', age:123)
def b = new GroovyObject(name:'jiming2', age:13, next:a)


println jsonMapper.writeValueAsString(b);

